/*
package com.yc.fx.webApi.job;

import com.yc.fx.webApi.service.AutoAllocateService;
import com.yc.fx.webApi.serviceImpl.AutoAllocateServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

@Component
public class AutoAllocateJob {

    @Resource
    private AutoAllocateServiceImpl autoAllocateServiceImpl;

    @PostConstruct
    public void timerRun() {
        String sTime = "9:28:00";
        // 一天的毫秒数
        long daySpan = 24 * 60 * 60 * 1000;
        //long daySpan = 60 * 1000;
        // 规定的每天时间sTime运行
        StringBuilder strTime = new StringBuilder();
        strTime.append("yyyy-MM-dd ").append(sTime);
        System.out.println(strTime);
        SimpleDateFormat sdf = new SimpleDateFormat(strTime.toString());
        // 首次运行时间
        try {
            Date startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(sdf.format(new Date()));
            // 如果今天的已经过了 首次运行时间就改为明天
            if (System.currentTimeMillis() > startTime.getTime()) {
                startTime = new Date(startTime.getTime() + daySpan);
            }
            Timer t = new Timer();
            TimerTask task = new TimerTask() {
                @Override
                public void run() {
                    //TODO 自动分配新注册得公司或者企业给最近的网点得客户经理
                    autoAllocateServiceImpl.allocate();
                    System.out.println("自动分配客户经理已完成，时间:"+new Date());
                }
            };
            // 以每24小时执行一次
            t.schedule(task, startTime, daySpan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
*/
